import model.*;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/*
public class Main {
    public static void main(String[] args) {
        Pizza pizza = new BasicPizza();
        pizza = new CheeseDecorator(pizza);
        System.out.println(pizza.getDescription() + " - $" + pizza.getCost());
    }
}
*/public class Main {
   /* public static void main(String[] args) {
        MenuItem drink = new MenuItem(1, 1, "Coke", "Drink", 1.99);
        Pizza adaptedDrink = new FoodAdapter(drink);

        System.out.println(adaptedDrink.getDescription() + " - $" + adaptedDrink.getCost());
    }*/

    public static void main(String[] args) {
        System.out.println("Hello world!");
        try {
            Connection connection = DatabaseConnection.getConnection();
            if (connection != null) {
                System.out.println("Connected to the database!");

                // 执行一个简单的查询来测试连接
                Statement statement = connection.createStatement();
                ResultSet resultSet = statement.executeQuery("SELECT 1");

                if (resultSet.next()) {
                    System.out.println("Query result: " + resultSet.getInt(1));
                } else {
                    System.out.println("No results returned from the query.");
                }

                // 关闭资源
                resultSet.close();
                statement.close();
                connection.close();
            } else {
                System.out.println("Failed to connect to the database.");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
